<?php
/**
 * Created by PhpStorm.
 * User: drawping
 * Date: 2017/3/6
 * Time: 下午8:51
 */

namespace Drawping\CarApi;

use Illuminate\Support\ServiceProvider as LaravelServiceProvider;

class ServiceProvider extends LaravelServiceProvider
{
    /**
     * 延迟加载.
     *
     * @var bool
     */
    protected $defer = false;

    public function boot()
    {
        $source = realpath(__DIR__ . '/config.php');
        if ($this->app->runningInConsole()) {
            $this->publishes([
                $source => config_path('jisuapi.php'),
            ]);
        }
        //$this->mergeConfigFrom($source, 'jisuapi');
    }
    public function register()
    {

        $this->app->singleton(Application::class, function ($laravelApp) {
            $app = new Application(config('jisuapi'));
            return $app;
        });

        $this->app->alias(Application::class, 'CarApi');
    }

    /**
     * 提供的服务
     *
     * @return array
     */
    public function provides()
    {
        return ['microapp', Application::class];
    }
}